package com.hlk.emos.wx.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.hlk.emos.wx.config.shiro.JwtUtil;
import com.hlk.emos.wx.service.CheckinService;
import com.hlk.emos.wx.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 签到表
 *
 * @author hlk hlk@gmail.com
 * @since v1.0.0 2021-05-19
 */
@RestController
@RequestMapping("/checkin")
@Api(tags = "签到表")
public class CheckinController {
    @Autowired
    private JwtUtil jwtUtil;
    @Autowired
    private CheckinService checkinService;

    @GetMapping("/validCanCheckIn")
    @ApiOperation("查看用户今天是否可以签到")
    public Result<String> validCanCheckIn(@RequestHeader("token") String token) {
        int userId = jwtUtil.getUserId(token);
        String result = checkinService.validCanCheckIn(userId);
        return new Result<String>().ok(result);
    }

}
